<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="java.util.Calendar" %>
<% String title = "信息综合系统"; %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<%@ page import="cn.qayy.constants.CollectionConstant"%>

<title><%=title %>-现金流管理</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="apple-itunes-app" content="app-id=429849944"/>
<meta name="apple-touch-fullscreen" content="no"/>
<meta content="telephone=no" name="format-detection"/>
<meta name="apple-mobile-web-app-capable" content="no"/>
</head>

<body class="fixed-top" style="background: #fff;">
<div class="container-fluid">
   <div class="row-fluid">
       <div class="span12">
           <ul class="breadcrumb" style="padding-bottom : 12px;background: #fff;">
               <li><a href="${pageContext.request.contextPath}/user/index.do">
               		<i class="icon-angle-left"></i>
					<i class="icon-angle-left"></i> &nbsp;&nbsp;
               		首页控制台</a>
                   <span class="divider">/</span></li>
               <li class="active">现金流管理</li>
               <li class="pull-right search-wrap">
	                 <button onclick="toggleCondi();" 
						class="btn dropdown-toggle" data-toggle="dropdown">
						<span id="but_text">隐藏筛选区域</span> 
						<i id="toggleCondi_i" class="icon-angle-up"></i>
					</button>
					&nbsp;&nbsp;
                    <div class="btn-group pull-right">
		              <button class="btn dropdown-toggle" data-toggle="dropdown">更多 <i class="icon-angle-down"></i>
		              </button>
		              <ul class="dropdown-menu pull-right">
		                  <li><a href="${pageContext.request.contextPath}/cashflow/download.do">下载已筛选现金记录</a></li>
		                  <li><a href="#" onclick="openUpload();">Excel批量上传N条</a></li>
		                  <li><a href="#" onclick="showOpen(0,'新增');">页面新增一条</a></li>
		              </ul>
          			</div>     
               </li>
           </ul>
       </div>
   </div>
   
   <div class="widget">
   	   <!-- 查询条件 -->
       <div class="row-fluid">
           <div class="clearfix" >
           <form method="post" id="filterForm">
               <input type="text" class="span2" id="cashFlowId" name = "id" placeholder="请填写ID" data-provide="typeahead"
                      data-items="4"/>
               <input type="text" class="span2 typeahead" name="chargeMan"
                      id="chargeMan" placeholder="填写负责人" data-provide="typeahead"
                      data-items="4" /> 
               
               <input type="text" class="span1 typeahead" name="client"
                      id="client" placeholder="填写客户" data-provide="typeahead"
                      data-items="4" /> 
               
               <input type="text" name="deliveryDate" id="deliveryDate"
                      class="Wdate" style="width: 120px;" placeholder="请填写发货日期"
                      onfocus="WdatePicker({isShowClear:false,readOnly:false,dateFmt:'yyyy/MM/dd'})" />
               
               <input type="text" class="span2 typeahead" name="outNumber"
                      id="outNumber" placeholder="填写出库单号" data-provide="typeahead"
                      data-items="4" /> 
               
               <input type="text" class="span2 typeahead" name="batchNumber"
                      id="batchNumber" placeholder="填写批号" data-provide="typeahead"
                      data-items="4" />
                                   
               <!-- <input type="text" name="count" class="span3 typeahead noNull"
                      style="width: 100px;" id="count" placeholder="请填写数量"
                      onblur="if(!/^\d{1,9}$/.test(this.value)){layer.msg('只能输入数字');this.value='';}" />
               
               <input type="text" name="pCount" class="span3 typeahead noNull"
                      style="width: 100px;" id="pCount" placeholder="请填写生产折量"
                      onblur="if(!/^\d{1,9}$/.test(this.value)){layer.msg('只能输入数字');this.value='';}" />
                                  
               <input type="text" name="xsCount" class="span3 typeahead noNull"
                      style="width: 100px;" id="xsCount" placeholder="请填写销售折量"
                      onblur="if(!/^\d{1,9}$/.test(this.value)){layer.msg('只能输入数字');this.value='';}" />  
                                
               <input type="text" name="price" class="span3 typeahead noNull"
                      style="width: 100px;" id="price" placeholder="请填写价格"
                      onblur="if(!/^\d{1,9}$/.test(this.value)){layer.msg('只能输入数字');this.value='';}" />
                                  
               <input type="text" name="ableCash" class="span3 typeahead noNull"
                      style="width: 100px;" id="ableCash" placeholder="请填写可用现金"
                      onblur="if(!/^\d{1,9}$/.test(this.value)){layer.msg('只能输入数字');this.value='';}" />  
                        -->   
               <input type="text" class="span2 typeahead" name="tradeName"
                                   id="tradeName" placeholder="填写收付方名称" data-provide="typeahead"
                                   data-items="4" />  
               
               <input type="text" class="span2 typeahead" name="tradeDate"
                                   id="tradeDate" placeholder="填写收付方日期" data-provide="typeahead"
                                   data-items="4" />  
                                   
               <input type="text" class="span2 typeahead" name="business"
                                   id="business" placeholder="填写商业" data-provide="typeahead"
                                   data-items="4" />  
                                   
                <input type="text" class="span2 typeahead" name="makeTicketDate"
                                   id="makeTicketDate" placeholder="填写开票日期" data-provide="typeahead"
                                   data-items="4" />  
                                   
               <input type="text" class="span2 typeahead" name="invoice"
                                   id="invoice" placeholder="填写发票/收据号" data-provide="typeahead"
                                   data-items="4" />  
                                   
               <input type="text" class="span2 typeahead" name="checkTaker"
                                   id="checkTaker" placeholder="填写收票人及联系方式" data-provide="typeahead"
                                   data-items="4" /> 
                                   
               <input type="text" class="span2 typeahead" name="invoiceAddr"
                                   id="invoiceAddr" placeholder="填写收货地址" data-provide="typeahead"
                                   data-items="4" /> 
                                   
               <select id = "companyBranch" name="companyBranch" size="1" class="input-medium m-wrap">
                     <option value="">请选择公司分支</option>
                     <option value = "新疆" >新疆</option>
                     <option value = "深圳" >深圳</option>
               </select>
               
               <select id = "belongYear" name="belongYear" size="1" class="input-medium m-wrap">
                   <option value="">请选择归属年限</option>
                    <c:forEach items="${years}" var="year">
                         <option value="${year}">${year}</option>
                    </c:forEach>
               </select>
               
               <select id = "realYear" name="realYear" size="1" class="input-medium m-wrap">
                     <option value="">请选择实际年限</option>
                      <c:forEach items="${years}" var="year">
                         <option value="${year}">${year}</option>
                      </c:forEach>
               </select>
               
               <select id = "stripLine" name="stripLine" size="1" class="input-medium m-wrap">
                    <option value="" >请选择条线</option>
                     <option value=""> </option>
                     <option value = "N/A" >N/A</option>
                     <option value = "OTC" >OTC</option>
                     <option value = "Rx" >Rx</option>
                     <option value = "管理费用" >管理费用</option>
               </select>
               
               <select id = "costType" name="costType" size="1" class="input-medium m-wrap">
                     <option value="">请选择费用类型</option>
                     <option value = "N/A" >N/A</option>
                     <option value = "管理费用" >管理费用</option>
                     <option value = "销售费用" >销售费用</option>
               </select>
               
               <select id = "product" name="product" size="1" class="input-medium m-wrap">
                    <option value="" >请选择品种</option>
                    <option value = "N/A" >N/A</option>
                     <option value = "安" >安</option>
                     <option value = "贝" >贝</option>
                     <option value = "银" >银</option>
               </select>  
               
               <select id = "department" name="department" size="1" class="input-medium m-wrap">
                     <option value="">请选择部门</option>
                     <c:forEach items="${department}" var="dept">
                         <option value="${dept}">${dept}</option>
                     </c:forEach>
               </select>
               
               <select id = "province" name="province" size="1" class="input-medium m-wrap">
                     <option value=""> 请选择省份</option>
                     <c:forEach items="${condiMap.shengfen}" var="shenfen">
                         <option value="${shenfen}">${shenfen}</option>
                     </c:forEach>
               </select>
          
               <select id = "project" name="project" size="1" class="input-medium m-wrap">
                     <option value="">请选择项目</option>
                     <c:forEach items="${projects}" var="project">
                         <option value="${project}">${project}</option>
                     </c:forEach>
               </select> 
               
               <select id = "secondLevel" name="secondLevel" size="1" class="input-medium m-wrap">
                     <option value=""> 请选择二级科目</option>
                     <c:forEach items="${secondLevel}" var="second">
                         <option value="${second}">${second}</option>
                     </c:forEach>
               </select>  
               
               <select id = "threeLevel" name="threeLevel" size="1" class="input-medium m-wrap">
                     <option value="">请选择三级科目</option>
                     <c:forEach items="${threeLevel}" var="three">
                         <option value="${three}">${three}</option>
                     </c:forEach>
               </select> 
               
               <select id = "fourLevel" name="fourLevel" size="1" class="input-medium m-wrap">
                     <option value="">请选择四级科目</option>
                     <c:forEach items="${fourLevel}" var="four">
                         <option value="${four}">${four}</option>
                     </c:forEach>
               </select> 
               
               <select id = "bank" name="bank" size="1" class="input-medium m-wrap">
                     <option value="" >请选择银行</option>
                     <c:forEach items="${banks}" var="bank">
                         <option value="${bank}">${bank}</option>
                     </c:forEach>
               </select>  
           <input type="button" id="seach" name="seach" value="查询" class="btn  btn-primary"
                      style="margin-bottom: 10px;"
                      onclick="query(pNumber,pSize);">
           <input type="reset" id="reset" name="reset" value="重置该页面" class="btn  btn-primary"
     			style="margin-bottom: 10px;" onclick="resetf();"/>
           </form>
           </div>
       </div>
       
       <!-- 新增、修改表单-->
       <div id="form_div" hidden>
           <div class="modal-body" style="height: 90%">
            <form action="${pageContext.request.contextPath }/cashFlow/addCashFlow.do" method="post" id="submitForm">
               <input id="cashFlowIdU" value="" hidden = "hidden" name="id">
                                                               项目:
               <input type="text" class="span2 typeahead" name="project"
                                   id="projectU"  data-provide="typeahead"
                                   data-items="4" /> 
                                                               二级科目:
               <input type="text" class="span2 typeahead" name="secondLevel"
                                   id="secondLevelU"  data-provide="typeahead"
                                   data-items="4" /> 
                                                              三级科目:
               <input type="text" class="span2 typeahead" name="threeLevel"
                                   id="threeLevelU"  data-provide="typeahead"
                                   data-items="4" /> 
               <br/>四级科目:
               <input type="text" class="span2 typeahead" name="fourLevel"
                                   id="fourLevelU"  data-provide="typeahead"
                                   data-items="4" /> 
                                                               收款客户名称:
               <input type="text" class="span2 typeahead" name="receiptClientName"
                      id="receiptClientNameU" data-provide="typeahead"
                      data-items="4" /> 
                                                               部门:
               <input type="text" class="span2 typeahead" name="department"
                                   id="departmentU"  data-provide="typeahead"
                                   data-items="4" />        
               <br/> 负责人：
               <input type="text" class="span2 typeahead" name="chargeMan"
                      id="chargeManU" placeholder="填写负责人" data-provide="typeahead"
                      data-items="4" /> 
                                                              客户：
               <input type="text" class="span1 typeahead" name="client"
                                   id="clientU" data-provide="typeahead"
                                   data-items="4" /> 
                                                                出库单号:                       
               <input type="text" class="span1 typeahead" name="outNumber"
                                   id="outNumberU" data-provide="typeahead"
                                   data-items="4" /> 
                                                                批号:
               <input type="text" class="span1 typeahead" name="batchNumber"
                                   id="batchNumberU" data-provide="typeahead"
                                   data-items="4" />    
                                                               数量: 
               <input type="text" name="count" class="span3 typeahead"
                                  style="width: 100px;" id="countU"
                                  onblur="if(!/^\d{1,9}$/.test(this.value)){layer.msg('只能输入数字');this.value='';}" />
                                                             <!--   生产折量: 
               <input type="text" name="pCount" class="span1 typeahead"
                                  style="width: 100px;" id="pCountU"
                                  onblur="if(!/^\d{1,9}\.{0,1}\d{1,4}?$/.test(this.value)){layer.msg('只能输入数字');this.value='';}" />
                                                                销售折量: 
               <input type="text" name="xsCount" class="span1 typeahead"
                                  style="width: 100px;" id="xsCountU"
                                  onblur="if(!/^\d{1,9}\.{0,1}\d{1,4}?$/.test(this.value)){layer.msg('只能输入数字');this.value='';}" />  
                                                               -->  价格: 
               <input type="text" name="price" class="span1 typeahead"
                                  style="width: 100px;" id="priceU"
                                  onblur="if(!/^\d{1,9}\.{0,1}\d{1,4}?$/.test(this.value)){layer.msg('只能输入数字');this.value='';}" />
                                                                可用现金: 
               <input type="text" name="ableCash" class="span1 typeahead"
                                  style="width: 100px;" id="ableCashU"
                                  onblur="if(!/^\d{1,9}\.{0,1}\d{1,4}?$/.test(this.value)){layer.msg('只能输入数字');this.value='';}" />  
                                                                 收付方名称:
               <input type="text" class="span2 typeahead" name="tradeName"
                                   id="tradeNameU" data-provide="typeahead"
                                   data-items="4" />  
               <br/> 收付方日期:
               <input type="text" class="span2 typeahead" name="tradeDate"
                                   id="tradeDateU" data-provide="typeahead"
                                   data-items="4" />  
                                                                 商业:                  
               <input type="text" class="span2 typeahead" name="business"
                                   id="businessU" data-provide="typeahead"
                                   data-items="4" />  
                                                                开票日期：                
               <input type="text" class="span2 typeahead" name="makeTicketDate"
                                   id="makeTicketDateU" data-provide="typeahead"
                                   data-items="4" />  
               <br/>发票/收据号：
               <input type="text" class="span2 typeahead" name="invoice"
                                   id="invoiceU" data-provide="typeahead"
                                   data-items="4" />  
                                                                收票人及联系方式：                
               <input type="text" class="span2 typeahead" name="checkTaker"
                                   id="checkTakerU" data-provide="typeahead"
                                   data-items="4" /> 
               <br/> 收票地址：
               <input type="text" class="span2 typeahead" name="invoiceAddr"
                                   id="invoiceAddrU"  data-provide="typeahead"
                                   data-items="4" /> 
                                                               包装:
               <select id="packU" name="pack" class="input-medium m-wrap" >
                   <option value=""></option>
                   <c:forEach items="${packs}" var="pack" >
                       <option value="${pack}">${pack}</option>
                   </c:forEach>
               </select> 
                                                               公司分支:
               <select id = "companyBranchU" name="companyBranch"  size="1" class="input-medium m-wrap">
                     <option value = "新疆" >新疆</option>
                     <option value = "深圳" >深圳</option>
               </select>
               
               <br/> 归属年限:
               <select id = "belongYearU" name="belongYear"  size="1" class="input-medium m-wrap">
                      <c:forEach items="${years}" var="year">
                         <option value="${year}">${year}</option>
                      </c:forEach>
               </select>
                                                                实际年限:
               <select id = "realYearU" name="realYear"  size="1" class="input-medium m-wrap">
                      <c:forEach items="${years}" var="year">
                         <option value="${year}">${year}</option>
                      </c:forEach>
               </select>
                                                               条线:
               <select id = "stripLineU" name="stripLine"  size="1" class="input-medium m-wrap">
                     <option value=""></option>
                     <option value = "N/A" >N/A</option>
                     <option value = "OTC" >OTC</option>
                     <option value = "Rx" >Rx</option>
                     <option value = "管理费用" >管理费用</option>
               </select>
               <br/>  费用类型:
               <select id = "costTypeU" name="costType"  size="1" class="input-medium m-wrap">
                     <option value=""></option>
                     <option value = "N/A" >N/A</option>
                     <option value = "管理费用" >管理费用</option>
                     <option value = "销售费用" >销售费用</option>
               </select>
                                                              省份:
               <select id = "provinceU" name="province"  size="1" class="input-medium m-wrap">
                     <option value=""></option>
                     <c:forEach items="${condiMap.shengfen}" var="shenfen">
                         <option value="${shenfen}">${shenfen}</option>
                     </c:forEach>
               </select>
                                                              发货日期:
               <input type="text" name="deliveryDate" id="deliveryDateU"
                    class="Wdate" style="width: 120px;"
                   onfocus="WdatePicker({isShowClear:false,readOnly:false,dateFmt:'yyyy/MM/dd'})" />
               <br/> 品种:
               <select id = "productU" name="product"  size="1" class="input-medium m-wrap">
                     <option value = "" ></option>
                     <option value = "N/A" >N/A</option>
                     <option value = "A" >A</option>
                     <option value = "Y" >Y</option>
                     <option value = "Z" >Z</option>
               </select>  
                                                                银行:
               <select id = "bankU" name="bank"  size="1" class="input-medium m-wrap">
                     <option value = "" ></option>
                     <c:forEach items="${banks}" var="bank">
                       <option value="${bank}">${bank}</option>
                     </c:forEach>
                        </select> 
                        <br/>财务备注:     
                        <textarea rows="3" cols="80" name ="financialMemo" id="financialMemoU" placeholder=""></textarea> 
                                                                         明细项备注: 
                        <textarea rows="3" cols="80" name ="detailMemo" id="detailMemoU" ></textarea>
                        <br/>收货备注:
                        <textarea rows="3" cols="80" name ="receivingMemo" id="receivingMemoU" ></textarea> 
                     </form>
                    </div>
                </div>
                
        <!-- 文件上传 -->
		<div id="uploadFileForm" hidden>
			<div class="modal-body">
				<form
					action="${pageContext.request.contextPath}/cashflow/upload.do"
					method="post" id="uploadForm" enctype="multipart/form-data">
					点击该按钮选择文件:<input type="file" name="excelFile"
						multiple="multiple" class="input-medium" id="file"><br/>
				</form>
			</div>
		</div>

		<!-- 错误提示-->
		<div id="errorInfoDiv" hidden="hidden">
			<table class="table table-striped table-hover table-bordered" style="font-size:11px;color:red;width:750px;margin:12px;">
				<thead>
					<tr>
						<td>出错行号</td>
						<td>出错标题</td>
						<td>标准字段</td>
						<td>错误字段</td>
					</tr>
				</thead>
				<tbody id="error-body"></tbody>
			</table>
		</div>


				<div class="row-fluid">
                	<div class="span12">
                    <!-- BEGIN ALERTS PORTLET-->
           <div class="widget blue">
               <div class="widget-title">
                   <h4><i class="icon-reorder"></i>
                       <a href="javascript:;" onclick="scrollToLeft();" title="定位到表格最左端" style ="color:white;">最左</a>
		                <a href="javascript:;" onclick="scrollToCenter();" title="定位到表格正中间" style ="color:white;">居中</a>
		                <a href="javascript:;" onclick="scrollToRight();" title="定位到表格最右端" style ="color:white;">最右</a>
                        <a href="javascript:;" id="getProp" style ="color:white;margin-left:0px;">复制</a>
                     </h4>
					    <span class="tools">
						<a href="javascript:;" class="icon-chevron-down"></a>
					</span>
                 </div>
 
                <div class="widget-body" style="overflow:auto" id="canvas-wrap">
                <div class="pageBottom" style="text-align:center;">
                    <input type="hidden" id="page-size" value="0"/>
                    <div id="callBackPager" class="paging_bootstrap pagination"></div> 
                </div>
               	<table class="table table-striped table-hover table-bordered" width="640px;"
                  		style="table-layout:fixed">
                       <thead>
                        <tr>
                       <th style="width:15px;"><input type="checkbox" name="choiceAll" value="all" id ="allAndNotAll" onclick="allAndNotAll(this,'cashflow');"/></th>
                       <th width="20px;">id</th>
                       <th width="70px">公司分支</th>
						<th width="70px">归属年限</th>
						<th width="70px">实际年限</th>
						<th width="70px">条线</th>
						<th width="70px">费用类别</th>
						<th width="70px">负责人</th>
						<th width="70px">部门</th>
						<th width="70px">省份</th>
						<th width="70px">项目</th>
						<th width="70px">二级科目</th>
						<th width="70px">三级科目</th>
						<th width="70px">四级科目</th>
						<th width="70px">客户</th>
						<th width="70px">明细项备注</th>
						<th width="70px">发货日期</th>
						<th width="70px">T年</th>
						<th width="70px">T月</th>
						<th width="70px">T日</th>
						<th width="70px">出库单号</th>
						<th width="70px">批号</th>
						<th width="70px">品种</th>
						<th width="70px">包装</th>
						<th width="70px">数量</th>
						<th width="70px">生产折量</th>
						<th width="70px">销售折量</th>
						<th width="70px">价格</th>
						<th width="70px">可用现金</th>
						<th width="70px">财务备注</th>
						<th width="70px">银行</th>
						<th width="170px">收(付)方日期</th>
						<th width="170px">收(付)方名称</th>
						<th width="170px">收款客户名称</th>
						<th width="170px">商业</th>
						<th width="70px">开票日期</th>
						<th width="70px">发票/收据号</th>
						<th width="150px">收票人及联系方式</th>
						<th width="170px">收票地址</th>
						<th width="70px">收货备注</th>
					</tr>
                       </thead>
                    <tbody id="distribute-body">
               		</tbody>
                   </table>
               </div>

           </div>
           <!-- END ALERTS PORTLET-->
       	</div>
   	</div>
      
   </div>
</div>


<!-- 页面模板基本js -->
<script src="${pageContext.request.contextPath}/js/jquery-1.7.1.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.nicescroll.js" type="text/javascript"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-ui-1.9.2.custom.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.slimscroll.min.js"></script>
<script src="${pageContext.request.contextPath}/js/fullcalendar.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.easy-pie-chart.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.sparkline.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/Chart.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.scrollTo.min.js"></script>
<script src="${pageContext.request.contextPath}/js/common-scripts.js"></script>
<!--layer-->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/layer/layer.js"></script>
<!--下拉多选过滤-->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap-multiselect.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap-multiselect.css" type="text/css"/>
<!--自动补全-->
<script src="${pageContext.request.contextPath}/js/bootstrap-typeahead.js"></script>
<!--分页-->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/extendPagination.js"></script>
<!--日期-->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/My97DatePicker/WdatePicker.js"></script>
<!--复制-->
<script src="${pageContext.request.contextPath}/js/jquery.zclip.min.js" type="text/javascript" ></script>

<!-- END JAVASCRIPTS -->
<!-- 自定义的script方法 -->
<script type="text/javascript">
    $(document).ready(function () {
    	setTimeout("selectMoreItem('province','请选择省份','100px');",10);
    	setTimeout("selectMoreItem('product','请选择品种','100px');",10);
    	setTimeout("selectMoreItem('pack','请选择包装','100px');",10);
    	setTimeout("selectMoreItem('companyBranch','请选择公司分支','120px');",10);
    	setTimeout("selectMoreItem('belongYear','请选择归属年限','120px');",10);
    	setTimeout("selectMoreItem('realYear','请选择实际年限','120px');",10);
    	setTimeout("selectMoreItem('stripLine','请选择条线','100px');",10);
    	setTimeout("selectMoreItem('costType','请选择费用类型','120px');",10);
    	setTimeout("selectMoreItem('department','请选择部门','100px');",10);
    	setTimeout("selectMoreItem('project','请选择项目','100px');",10);
    	setTimeout("selectMoreItem('secondLevel','请选择二级科目','120px');",10);
    	setTimeout("selectMoreItem('threeLevel','请选择三级科目','120px');",10);
    	setTimeout("selectMoreItem('fourLevel','请选择四级科目','120px');",10);
    	setTimeout("selectMoreItem('bank','请选择银行','100px');",10);
    });
</script>

<!--查询符合筛选条件的流向记录 -->
<script type="text/javascript">
    //异步请求获取符合筛选条件的流向记录
    function query(pageNumber, pageSize) {
		var url = "${pageContext.request.contextPath }/cashflow/selectForList.do?pageNumber="
				+ pageNumber + "&pageSize=" + pageSize;
    	var params = $("#filterForm").serialize();
    	queryList(url,params);
    }

    //动态创建table
    function createTable(currPage, limit, total, items) {
        var html = [], showNum = limit;
        if (total - (currPage * limit) < 0) showNum = total - ((currPage - 1) * limit);
        for (var i = 0; i < showNum; i++) {
            html.push("<tr ondblclick=\"showOpen('"+items[i].id+"','修改')\" >");
            html.push('<td><input type="checkbox" name="choice" value="'+items[i].id+'"/></td>');
            html.push('<td>' + formatData(items[i].id) + '</td>');
            html.push('<td>' + formatData(items[i].companyBranch) + '</td>');
        	html.push('<td>' + formatData(items[i].belongYear) + '</td>');
        	html.push('<td>' + formatData(items[i].realYear) + '</td>');
        	html.push('<td>' + formatData(items[i].stripLine) + '</td>');
        	html.push('<td>' + formatData(items[i].costType) + '</td>');
        	html.push('<td>' + formatData(items[i].chargeMan) + '</td>');
        	html.push('<td>' + formatData(items[i].department) + '</td>');
        	html.push('<td>' + formatData(items[i].province) + '</td>');
        	html.push('<td>' + formatData(items[i].project) + '</td>');
            html.push('<td>' + formatData(items[i].secondLevel) + '</td>');
            html.push('<td>' + formatData(items[i].threeLevel) + '</td>');
            html.push('<td>' + formatData(items[i].fourLevel) + '</td>');
            html.push('<td>' + formatData(items[i].client) + '</td>');
            html.push('<td>' + formatData(items[i].detailMemo) + '</td>');
            html.push('<td>' + formatData(items[i].deliveryDate) + '</td>');
            html.push('<td>' + formatData(items[i].tYear) + '</td>');
            html.push('<td>' + formatData(items[i].tMonth) + '</td>');
            html.push('<td>' + formatData(items[i].tDay) + '</td>');
            html.push('<td>' + formatData(items[i].outNumber) + '</td>');
            html.push('<td>' + formatData(items[i].batchNumber) + '</td>');
            html.push('<td>' + formatData(items[i].product) + '</td>');
            html.push('<td>' + formatData(items[i].pack) + '</td>');
            html.push('<td>' + formatData(items[i].count) + '</td>');
            html.push('<td>' + formatData(items[i].pCount) + '</td>');
            html.push('<td>' + formatData(items[i].xsCount) + '</td>');
            html.push('<td>' + formatData(items[i].price) + '</td>');
            html.push('<td>' + formatData(items[i].ableCash) + '</td>');
            html.push('<td>' + formatData(items[i].financialMemo) + '</td>');
            html.push('<td>' + formatData(items[i].bank) + '</td>');
            html.push('<td>' + formatData(items[i].tradeDate) + '</td>');
            html.push('<td>' + formatData(items[i].tradeName) + '</td>');
            html.push('<td>' + formatData(items[i].receiptClientName) + '</td>');
            html.push('<td>' + formatData(items[i].business) + '</td>');
            html.push('<td>' + formatData(items[i].makeTicketDate) + '</td>');
            html.push('<td>' + formatData(items[i].invoice) + '</td>');
            html.push('<td>' + formatData(items[i].checkTaker) + '</td>');
            html.push('<td>' + formatData(items[i].invoiceAddr) + '</td>');
            html.push('<td>' + formatData(items[i].receivingMemo) + '</td>');
            html.push('</tr>');
        }
        var mainObj = $('#distribute-body');
        mainObj.empty();
        mainObj.html(html.join(''));
    };
</script>
<!-- END BODY -->


<!-- 新增、更新 -->
<script type="text/javascript">
	var htmls = $("#form_div").html();
    var ret = null;
    var open = false;
    function showOpen(id,type) {
        $("#form_div").remove();
        layer.open({
            title: [type+'<span style="color:red;font-size:12px;margin-left:10px;">*表示该项必填</span>', 'font-size:18px;'],
            type:1,
            content: htmls, //这里content是一个普通的String
            btn: ['确认', '取消'],
            yes: function(index, layero){
            	var ret = checkNull("submitForm");
				if (ret == "false") {
					open = true;
					return open;
				}
				//一点击确认就关闭对话框
	         	layer.closeAll();
	         	//加载等待框
	         	layer.load(2);
            	var action ="";
                if("新增"==type){
                	action = "${pageContext.request.contextPath }/cashflow/saveOrUpdate.do?flag=N";
                }else if("修改"==type){
                	action = "${pageContext.request.contextPath }/cashflow/saveOrUpdate.do?flag=E";
                }
                var params = $("#submitForm").serialize();
				sendRequest(action, params, function(result) {
					var code = result.code;
					if (code == -2) { //excel校验不通过
						open = true;
						errorInfo(result.msg);
					} else if (code == -1) { // 有错误
						layer.alert(result.msg);
					} else if (code > 0) {
						//查询方法里有关闭load(2)的方法
						query(pNumber, pSize);
						layer.alert(result.msg);
					}
				});
				return open;
            }
            ,cancel: function(){
            	layer.closeAll();
            }
            ,area: ['800px', '500px']
        });
        
        //修改时，异步回显数据
        if("修改"==type){
        	var url = "${pageContext.request.contextPath }/cashflow/selectByID.do";
			sendRequest(url,{"id" : id},function(result) {
				var code = result.code;
				var ret = result.msg;
				if (code > 0) {
					$("#cashFlowIdU").val(id);  //动态赋值ID
					$("#companyBranchU").val(ret.companyBranch);
		            $("#belongYearU").val(ret.belongYear);
		        	$("#realYearU").val(ret.realYear);
		        	$("#stripLineU").val(ret.stripLine);
		        	$("#costTypeU").val(ret.costType);
		        	$("#chargeManU").val(ret.chargeMan);
		        	$("#departmentU").val(ret.department);
		        	$("#provinceU").val(ret.province);
		        	$("#projectU").val(ret.project);
		            $("#secondLevelU").val(ret.secondLevel);
		            $("#threeLevelU").val(ret.threeLevel);
		            $("#fourLevelU").val(ret.fourLevel);
		            $("#clientU").val(ret.client);
		            $("#detailMemoU").val(ret.detailMemo);
		            $("#deliveryDateU").val(ret.deliveryDate);
		            $("#outNumberU").val(ret.outNumber);
		            $("#batchNumberU").val(ret.batchNumber);
		            $("#productU").val(ret.product);
		            $("#countU").val(ret.count);
		            $("#pCountU").val(ret.pCount);
		            $("#xsCountU").val(ret.xsCount);
		            $("#priceU").val(ret.price);
		            $("#ableCashU").val(ret.ableCash);
		            $("#financialMemoU").val(ret.financialMemo);
		            $("#bankU").val(ret.bank);
		            $("#tradeNameU").val(ret.tradeName);
		            $("#tradeDateU").val(ret.tradeDate);
		            $("#businessU").val(ret.business);
		            $("#makeTicketDateU").val(ret.makeTicketDate);
		            $("#invoiceU").val(ret.invoice);
		            $("#checkTakerU").val(ret.checkTaker);
		            $("#invoiceAddrU").val(ret.invoiceAddr);
		            $("#receiptClientNameU").val(ret.receiptClientName);
		            $("#receivingMemoU").val(ret.receivingMemo);
		          	//新增、更新界面的下拉多选过滤 
				}
			});
        } else {
        	//新增、更新界面的下拉多选过滤 
         	var url = "${pageContext.request.contextPath }/register/nothing.do";
    		sendRequest(url,null,function(result) {
    			var code = result.code;
    			var ret = result.msg;
    			if (code > 0) {
    				 //新增、更新界面的下拉多选过滤 
    			}
    		});
        }
    	
    	//新增、更新界面的自动补全 数据填充
    	var dept = ${deptJson};
        console.log(dept);
        $('#departmentU').typeahead({source: dept});
        var project = ${proJson};
        $('#projectU').typeahead({source: project});
        var secondLevel = ${secondJson};
        $('#secondLevelU').typeahead({source: secondLevel});
        var threeLevel = ${threeJson};
        $('#threeLevelU').typeahead({source: threeLevel});
        var fourLevel = ${fourJson};
        $('#fourLevelU').typeahead({source: fourLevel});
    }
</script>
<script src="${pageContext.request.contextPath}/javascript/httpService.js"></script>
</body>
</html>